Skip to content

test: 🚨 exhaustive behavioral coverage for all scripts - #4

Merged
tomgrv merged 2 commits into
developfrom
claude/script-tests-readme-70kes2
Sep 4, 2026
Merged

test: 🚨 exhaustive behavioral coverage for all scripts#4
tomgrv merged 2 commits into
developfrom
claude/script-tests-readme-70kes2

Conversation

@tomgrv

@tomgrv tomgrv commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaced the syntax-only test.bats (previously just "installed on PATH + sh -n valid") in every one of the 53 script folders with a real behavioral suite: help/usage output, argument validation, error paths (missing/invalid args, running outside a git repo), success paths, and script-specific edge cases — run against throwaway git repos or temp directories via tests/helpers.bash.
  • Suites are hermetic: no network access, no writes outside temp dirs (network-only paths, e.g. zz_npx/zz_update's real npm/git-remote fetches, are covered by asserting the local-fixture fast path and that no network call occurs).
  • 417 tests now pass (npm test / bats --recursive .), up from the previous syntax-only checks.
  • Writing real tests surfaced and fixed 8 pre-existing bugs (minimal fixes, same behavior otherwise):
    • load-json: error exit 1s were silently swallowed because they lived inside an if/elif block piped into sed | jq, and jq exits 0 on empty stdin.
    • git-fix-base, git-fix-children, git-fix-date, git-fix-message, git-fix-privacy, git-fix-secrets: several destructive-rewrite scripts checked zz_ask's exit code (if ! zz_ask ...) instead of its printed answer, so answering "n" to "This will rewrite history, continue?" never actually cancelled the operation.
    • git-fix-base: the -n dry-run heredoc declared an invalid shell variable name (dry-run), so the flag never worked.
    • git-fix-children: grep's "no match" exit code (a normal case: no descendant branches to delete) aborted the whole script under set -e.
  • Updated the root README.md's Tests section to describe the new coverage.

Test plan

  • npm test (bats --recursive .) — 417/417 passing
  • Each modified script re-verified individually with npx bats <dir>/test.bats

Generated by Claude Code

Replace the syntax-only test.bats in every script folder with real
behavioral suites (help/usage, argument validation, success/error paths,
edge cases) run against throwaway git repos or temp dirs.

Fixes surfaced by the new tests:
- load-json: error exits were swallowed by piping into sed|jq
- git-fix-base/-children/-date/-message/-privacy/-secrets: zz_ask return
  value was checked via exit code instead of stdout, so declining a
  destructive-rewrite confirmation prompt never actually cancelled it
- git-fix-base: dry-run heredoc variable name was an invalid identifier
- git-fix-children: grep no-match exit code aborted the whole script
@github-actions github-actions Bot changed the title test: exhaustive behavioral coverage for all scripts test: 🚨 exhaustive behavioral coverage for all scripts Sep 4, 2026
Expand each script's boilerplate "## Tests" section with a bullet
summary of what its test.bats suite actually exercises, matching the
exhaustive behavioral coverage added in the previous commit.

tomgrv commented Sep 4, 2026

Copy link
Copy Markdown
Owner Author

validate-pr-title failed on the latest push, but not due to this PR's diff: the job fails in its actions/setup-node step with Dependencies lock file is not found ... Supported file patterns: package-lock.json,npm-shrinkwrap.json,yarn.lock — before the actual title-validation step even runs. This repo has never had a lockfile committed, and the same failure just hit an unrelated PR (#5, unrelated commit) too, while it passed earlier on this same PR's prior commit. That's a pre-existing, repo-wide CI infra gap (the workflow's npm-cache step needs a lockfile that doesn't exist), not something introduced here.

Re-ran the failed job once. If it stays red, the underlying fix (adding a committed lockfile, or dropping cache: npm from the workflow) is outside this PR's scope.


Generated by Claude Code

@tomgrv
tomgrv marked this pull request as ready for review September 4, 2026 14:16
@tomgrv
tomgrv merged commit dfa83c0 into develop Sep 4, 2026
4 of 7 checks passed
@tomgrv
tomgrv deleted the claude/script-tests-readme-70kes2 branch September 4, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants